
***********************
***ANALYSIS***
***********************

*Leclerc, Vink, and Schmeets (2020)
*Replication do.file for: Citizenship Acquisition and Spatial Stratification: analysing immigrant residential mobility in the Netherlands
*This do-file includes all the stata commands necessary to execute the analysis (Table 2 - main paper & Table 10 - 15; Figure 2 - 8 of the supplementary materials
*Database located in \\cbsp.nl\Productie\Projecten\SAL\209253UM_FP_SEC1\Werk\Christophe\Paper 2\FILES PUBLICATION URBAN STUDIES\data_base_cit_acq_spa_strat.csv (available within CBS secured environment)
*More detailed description of the variables can be found in the codebook
*Figures 1 and 2 were executed with R (see R-script csv files)

**********
*Table 2
**********

stset START, failure(EVENT) id(ID) 


stcox CITIZENSHIP_LAG##i.INCOME_QUARTILES_LAG GENDER i.type_contract_lag i.MIGRATION_MOTIVE i.first_second_gem_lag_rec i.co_nationals_lag i.employment_buurt_lag i.number_children_cat_lag_rec number_buurt_lag i.HDI_INDEX_REC i.STEDGEM_LAG i.INCOME_FINAL_BUURT_QUARTILES_LAG, tvc(CITIZENSHIP_DUMMY)strata(FINAL_HOUSING_TYPE_LAG NATIVE_BORN_PARTNER_LAG SETTLEMENT_YEAR AGE_ARRIVAL_QUARTILES)


stcox CITIZENSHIP_LAG##i.type_contract_lag i.INCOME_QUARTILES_LAG GENDER i.MIGRATION_MOTIVE i.first_second_gem_lag_rec i.co_nationals_lag i.employment_buurt_lag i.number_children_cat_lag_rec number_buurt_lag i.HDI_INDEX_REC i.STEDGEM_LAG i.INCOME_FINAL_BUURT_QUARTILES_LAG, tvc(CITIZENSHIP_DUMMY)strata(FINAL_HOUSING_TYPE_LAG NATIVE_BORN_PARTNER_LAG SETTLEMENT_YEAR AGE_ARRIVAL_QUARTILES)


stset START, failure(COMPETING_RISK_FINAL == 2) id(ID)

stcox CITIZENSHIP_LAG##i.type_contract_lag i.INCOME_QUARTILES_LAG i.first_second_gem_lag_rec i.co_nationals_lag i.employment_buurt_lag i.number_children_cat_lag_rec number_buurt_lag i.INCOME_FINAL_BUURT_QUARTILES_LAG i.STEDGEM_LAG i.HDI_INDEX_REC i.AGE_ARRIVAL_QUARTILES, tvc(CITIZENSHIP_DUMMY) strata(MIGRATION_MOTIVE GENDER FINAL_HOUSING_TYPE_LAG SETTLEMENT_YEAR AGE_ARRIVAL_QUARTILES NATIVE_BORN_PARTNER_LAG)

stcox CITIZENSHIP_LAG##i.INCOME_QUARTILES_LAG i.type_contract_lag i.first_second_gem_lag_rec i.co_nationals_lag i.employment_buurt_lag i.number_children_cat_lag_rec number_buurt_lag i.NATIVE_BORN_PARTNER_LAG i.INCOME_FINAL_BUURT_QUARTILES_LAG i.STEDGEM_LAG i.HDI_INDEX_REC i.AGE_ARRIVAL_QUARTILES, tvc(CITIZENSHIP_DUMMY) strata(MIGRATION_MOTIVE GENDER FINAL_HOUSING_TYPE_LAG SETTLEMENT_YEAR NATIVE_BORN_PARTNER_LAG)

stset START, failure(COMPETING_RISK_FINAL == 1) id(ID)

stcox CITIZENSHIP_LAG##i.type_contract_lag i.INCOME_QUARTILES_LAG i.MIGRATION_MOTIVE i.employment_buurt_lag i.SETTLEMENT_YEAR EU i.number_children_cat_lag_rec number_buurt_lag i.HDI_INDEX_REC i.STEDGEM_LAG CITIZENSHIP_DUMMY i.INCOME_FINAL_BUURT_QUARTILES_LAG i.co_nationals_lag GENDER i.NATIVE_BORN_PARTNER_LAG, strata(FINAL_HOUSING_TYPE_LAG AGE_ARRIVAL_QUARTILES first_second_gem_lag_rec)

stcox CITIZENSHIP_LAG##i.INCOME_QUARTILES_LAG i.type_contract_lag i.MIGRATION_MOTIVE i.employment_buurt_lag i.SETTLEMENT_YEAR EU i.number_children_cat_lag_rec number_buurt_lag i.HDI_INDEX_REC i.STEDGEM_LAG CITIZENSHIP_DUMMY i.INCOME_FINAL_BUURT_QUARTILES_LAG i.co_nationals_lag GENDER i.NATIVE_BORN_PARTNER_LAG, strata(FINAL_HOUSING_TYPE_LAG AGE_ARRIVAL_QUARTILES first_second_gem_lag_rec)


****************************
***Table 10 - supp materials
****************************

stset START, failure(EVENT) id(ID) 

stcox CITIZENSHIP_LAG i.INCOME_QUARTILES_LAG GENDER i.type_contract_lag i.MIGRATION_MOTIVE i.first_second_gem_lag_rec i.co_nationals_lag i.employment_buurt_lag i.number_children_cat_lag_rec number_buurt_lag i.HDI_INDEX_REC i.STEDGEM_LAG i.INCOME_FINAL_BUURT_QUARTILES_LAG, tvc(CITIZENSHIP_DUMMY)strata(FINAL_HOUSING_TYPE_LAG NATIVE_BORN_PARTNER_LAG SETTLEMENT_YEAR AGE_ARRIVAL_QUARTILES)


****************************
***Table 11 - supp materials
****************************

****Turkish migrants
keep if origin_country == 6043


stset START, failure(EVENT) id(ID) 

stcox CITIZENSHIP_LAG i.INCOME_QUARTILES_LAG i.AGE_ARRIVAL_QUARTILES i.type_contract_lag i.MIGRATION_MOTIVE i.first_second_gem_lag_rec i.co_nationals_lag number_buurt_lag i.SETTLEMENT_YEAR i.STEDGEM_LAG i.employment_buurt_lag i.PARTNER_STATUS_LAG i.number_children_cat CITIZENSHIP_DUMMY i.INCOME_FINAL_BUURT_QUARTILES_LAG, strata(FINAL_HOUSING_TYPE_LAG GENDER PARTNER_STATUS_LAG)

****Moroccan migrants

keep if origin_country == 5022 

stset START, failure(EVENT) id(ID) 

stcox CITIZENSHIP_LAG i.INCOME_QUARTILES_LAG i.AGE_ARRIVAL_QUARTILES i.type_contract_lag GENDER i.first_second_gem_lag_rec i.co_nationals_lag i.employment_buurt_lag i.SETTLEMENT_YEAR i.number_children_cat_lag_rec number_buurt_lag i.STEDGEM_LAG i.INCOME_FINAL_BUURT_QUARTILES_LAG CITIZENSHIP_DUMMY, strata(FINAL_HOUSING_TYPE_LAG MIGRATION_MOTIVE PARTNER_STATUS_LAG)


**** No Turks and Moroccans 

drop if origin_country==6043 | origin_country==5022

stset START, failure(EVENT) id(ID) 

stcox CITIZENSHIP_LAG i.INCOME_QUARTILES_LAG i.AGE_ARRIVAL_QUARTILES i.type_contract_lag i.MIGRATION_MOTIVE i.first_second_gem_lag_rec i.co_nationals_lag EU  number_buurt_lag i.HDI_INDEX_REC i.SETTLEMENT_YEAR i.STEDGEM_LAG i.employment_buurt_lag i.INCOME_FINAL_BUURT_QUARTILES_LAG, tvc(CITIZENSHIP_DUMMY) strata(FINAL_HOUSING_TYPE_LAG PARTNER_STATUS_LAG number_children_cat GENDER)



*****************************
***Table 12 - supp. materials
*****************************

stset START, failure(COMPETING_RISK_FINAL == 1) id(ID)

stcox CITIZENSHIP_LAG i.type_contract_lag i.INCOME_QUARTILES_LAG i.MIGRATION_MOTIVE i.employment_buurt_lag i.SETTLEMENT_YEAR EU i.number_children_cat_lag_rec number_buurt_lag i.HDI_INDEX_REC i.STEDGEM_LAG CITIZENSHIP_DUMMY i.INCOME_FINAL_BUURT_QUARTILES_LAG i.co_nationals_lag GENDER i.NATIVE_BORN_PARTNER_LAG, strata(FINAL_HOUSING_TYPE_LAG AGE_ARRIVAL_QUARTILES first_second_gem_lag_rec)


stset START, failure(COMPETING_RISK_FINAL == 2) id(ID)

stcox CITIZENSHIP_LAG i.type_contract_lag i.INCOME_QUARTILES_LAG i.first_second_gem_lag_rec i.co_nationals_lag i.employment_buurt_lag i.number_children_cat_lag_rec number_buurt_lag i.INCOME_FINAL_BUURT_QUARTILES_LAG i.STEDGEM_LAG i.HDI_INDEX_REC i.SETTLEMENT_YEAR GENDER, tvc(CITIZENSHIP_DUMMY) strata(AGE_ARRIVAL_QUARTILES FINAL_HOUSING_TYPE_LAG MIGRATION_MOTIVE NATIVE_BORN_PARTNER_LAG)



*****************************
***Table 13 - supp. materials
*****************************

* Mobility for individuals with huurtoeslag (housing benefits)

stset START, failure(COMPETING_RISK_1 == 2) id(ID)

stcox CITIZENSHIP_LAG i.NATIVE_BORN_PARTNER_LAG  i.type_contract_lag  GENDER  i.first_second_gem_lag_rec i.employment_buurt_lag i.SETTLEMENT_YEAR number_buurt_lag i.HDI_INDEX_REC i.STEDGEM_LAG i.co_nationals_lag i.INCOME_FINAL_BUURT_QUARTILES_LAG CITIZENSHIP_DUMMY i.AGE_ARRIVAL_QUARTILES i.MIGRATION_MOTIVE, strata(PARTNER_STATUS_LAG FINAL_HOUSING_TYPE_LAG number_children_cat)

* Mobility for individuals without huurtoeslag (no housing benefits)

stset START, failure(COMPETING_RISK_1 == 3) id(ID)

stcox CITIZENSHIP_LAG GENDER i.SETTLEMENT_YEAR i.type_contract_lag  number_buurt_lag i.HDI_INDEX_REC i.STEDGEM_LAG i.FINAL_HOUSING_TYPE_LAG i.MIGRATION_MOTIVE i.first_second_gem_lag_rec i.co_nationals_lag i.employment_buurt_lag i.INCOME_FINAL_BUURT_QUARTILES_LAG CITIZENSHIP_DUMMY i.AGE_ARRIVAL_QUARTILES, strata(PARTNER_STATUS_LAG FINAL_HOUSING_TYPE_LAG number_children_cat)


*****************************
***Table 14 - supp. materials
*****************************

*Run Cox models for concentration > 25%

keep if ARRIVAL_CONC_ABOVE_25 == 1

stset START, failure(EVENT_2) id(ID) 

stcox CITIZENSHIP_LAG i.INCOME_QUARTILES_LAG i.type_contract_lag GENDER i.MIGRATION_MOTIVE i.first_second_gem_lag_rec i.co_nationals_lag i.employment_buurt_lag i.SETTLEMENT_YEAR i.number_children_cat_lag number_buurt_lag i.STEDGEM_LAG, tvc(CITIZENSHIP_DUMMY) strata(PARTNER_STATUS_LAG FINAL_HOUSING_TYPE_LAG HDI_INDEX_REC Age_arrival_rec)


* Run Cox models for concentration > 30%

keep if ARRIVAL_CONC_ABOVE_30 == 1

stset START, failure(EVENT_3) id(ID) 

stcox CITIZENSHIP_LAG i.INCOME_QUARTILES_LAG i.type_contract_lag GENDER i.MIGRATION_MOTIVE i.first_second_gem_lag_rec i.co_nationals_lag i.employment_buurt_lag i.SETTLEMENT_YEAR i.number_children_cat_lag number_buurt_lag i.STEDGEM_LAG, tvc(CITIZENSHIP_DUMMY) strata(PARTNER_STATUS_LAG FINAL_HOUSING_TYPE_LAG HDI_INDEX_REC Age_arrival_rec)


*****************************
***Table 15 - supp. materials
*****************************

keep if CITIZENSHIP_DUMMY == 1

stset START, failure(EVENT) id(ID) 

stcox CITIZENSHIP_LAG i.INCOME_QUARTILES_LAG i.Age_arrival_rec i.type_contract_lag GENDER i.co_nationals_lag i.employment_buurt_lag i.SETTLEMENT_YEAR i.number_children_cat_lag  number_buurt_lag i.HDI_INDEX_REC i.STEDGEM_LAG i.first_second_gem_lag_rec i.MIGRATION_MOTIVE, strata(PARTNER_STATUS_LAG FINAL_HOUSING_TYPE_LAG)

stcox CITIZENSHIP_LAG i.INCOME_QUARTILES_LAG i.Age_arrival_rec i.type_contract_lag GENDER i.co_nationals_lag i.employment_buurt_lag i.SETTLEMENT_YEAR i.number_children_cat_lag  number_buurt_lag i.HDI_INDEX_REC i.STEDGEM_LAG MEAN_YEARS_NAT i.first_second_gem_lag_rec i.MIGRATION_MOTIVE, strata(PARTNER_STATUS_LAG FINAL_HOUSING_TYPE_LAG)

****************************
***Table 16 - supp.materials
****************************

stset START, failure(EVENT) id(ID) 

stcox CITIZENSHIP_LAG i.INCOME_QUARTILES_LAG GENDER i.type_contract_lag i.MIGRATION_MOTIVE i.first_second_gem_lag_rec i.co_nationals_lag i.employment_buurt_lag i.number_children_cat_lag_rec number_buurt_lag i.HDI_INDEX_REC i.STEDGEM_LAG i.INCOME_FINAL_BUURT_QUARTILES_LAG CITIZENSHIP_DUMMY i.FINAL_HOUSING_TYPE_LAG i.NATIVE_BORN_PARTNER_LAG i.SETTLEMENT_YEAR i.AGE_ARRIVAL_QUARTILES

estat test

***************************
***Figures 2 - 8 
***************************

stset START, failure(EVENT) id(ID) 

stcox CITIZENSHIP_LAG i.INCOME_QUARTILES_LAG GENDER i.type_contract_lag i.MIGRATION_MOTIVE i.first_second_gem_lag_rec i.co_nationals_lag i.employment_buurt_lag i.number_children_cat_lag_rec number_buurt_lag i.HDI_INDEX_REC i.STEDGEM_LAG i.INCOME_FINAL_BUURT_QUARTILES_LAG CITIZENSHIP_DUMMY i.FINAL_HOUSING_TYPE_LAG i.NATIVE_BORN_PARTNER_LAG i.SETTLEMENT_YEAR i.AGE_ARRIVAL_QUARTILES

stphplot, by(AGE_ARRIVAL_QUARTILES)  adjust(CITIZENSHIP_LAG type_contract_lag GENDER MIGRATION_MOTIVE first_second_gem_lag_rec co_nationals_lag employment_buurt_lag SETTLEMENT_YEAR number_children_cat_lag FINAL_HOUSING_TYPE_LAG number_buurt_lag NATIVE_BORN_PARTNER_LAG HDI_INDEX_REC STEDGEM_LAG INCOME_FINAL_BUURT_QUARTILES_LAG CITIZENSHIP_DUMMY INCOME_FINAL_CAT_PANEL_LAG_1) 

stphplot, by(FINAL_HOUSING_TYPE_LAG)  adjust(CITIZENSHIP_LAG INCOME_FINAL_CAT_PANEL_LAG_1 AGE_ARRIVAL_QUARTILES type_contract_lag GENDER MIGRATION_MOTIVE first_second_gem_lag_rec co_nationals_lag employment_buurt_lag SETTLEMENT_YEAR number_children_cat_lag number_buurt_lag NATIVE_BORN_PARTNER_LAG HDI_INDEX_REC STEDGEM_LAG INCOME_FINAL_BUURT_QUARTILES_LAG NATIVE_BORN_PARTNER_LAG CITIZENSHIP_DUMMY)

stphplot, by(SETTLEMENT_YEAR)  adjust(CITIZENSHIP_LAG AGE_ARRIVAL_QUARTILES type_contract_lag GENDER MIGRATION_MOTIVE first_second_gem_lag_rec co_nationals_lag employment_buurt_lag number_children_cat_lag FINAL_HOUSING_TYPE_LAG number_buurt_lag HDI_INDEX_REC STEDGEM_LAG INCOME_FINAL_BUURT_QUARTILES_LAG NATIVE_BORN_PARTNER_LAG CITIZENSHIP_DUMMY INCOME_FINAL_CAT_PANEL_LAG_1) 

stphplot, by(NATIVE_BORN_PARTNER_LAG)  adjust(CITIZENSHIP_LAG INCOME_FINAL_CAT_PANEL_LAG_1 AGE_ARRIVAL_QUARTILES type_contract_lag GENDER MIGRATION_MOTIVE first_second_gem_lag_rec co_nationals_lag employment_buurt_lag SETTLEMENT_YEAR number_children_cat_lag number_buurt_lag NATIVE_BORN_PARTNER_LAG HDI_INDEX_REC STEDGEM_LAG INCOME_FINAL_BUURT_QUARTILES_LAG CITIZENSHIP_DUMMY FINAL_HOUSING_TYPE_LAG)

stphplot, by(CITIZENSHIP_DUMMY)  adjust(CITIZENSHIP_LAG INCOME_FINAL_CAT_PANEL_LAG_1 AGE_ARRIVAL_QUARTILES type_contract_lag GENDER MIGRATION_MOTIVE first_second_gem_lag_rec co_nationals_lag employment_buurt_lag SETTLEMENT_YEAR number_children_cat_lag FINAL_HOUSING_TYPE_LAG number_buurt_lag NATIVE_BORN_PARTNER_LAG HDI_INDEX_REC STEDGEM_LAG INCOME_FINAL_BUURT_QUARTILES_LAG NATIVE_BORN_PARTNER_LAG)

stphplot, by(HDI_INDEX_REC)  adjust(CITIZENSHIP_LAG AGE_ARRIVAL_QUARTILES type_contract_lag GENDER MIGRATION_MOTIVE first_second_gem_lag_rec co_nationals_lag employment_buurt_lag number_children_cat_lag FINAL_HOUSING_TYPE_LAG number_buurt_lag STEDGEM_LAG INCOME_FINAL_BUURT_QUARTILES_LAG NATIVE_BORN_PARTNER_LAG CITIZENSHIP_DUMMY INCOME_FINAL_CAT_PANEL_LAG_1) 
 

